package main

import (
	"bytes"
	"fmt"
	"strings"
)

func main() {
	n := 10
	str := "test"
	fmt.Println("AddString", AddString(n, str))
	fmt.Println("FmtSprintf", FmtSprintf(n, str))
	fmt.Println("StringsBuffer", StringsBuffer(n, str))
	fmt.Println("BytesBuffer", BytesBuffer(n, str))
	fmt.Println("Byte", Byte(n, str))

}

func AddString(n int, str string) string {
	s := ""
	for i := 0; i < n; i++ {
		s += str
	}
	return s
}

func FmtSprintf(n int, str string) string {
	s := ""
	for i := 0; i < n; i++ {
		s = fmt.Sprintf("%s%s", s, str)
	}
	return s
}

func StringsBuffer(n int, str string) string {
	var s strings.Builder
	for i := 0; i < n; i++ {
		s.WriteString(str)
	}

	return s.String()
}

func BytesBuffer(n int, str string) string {
	var s = new(bytes.Buffer)
	for i := 0; i < n; i++ {
		s.WriteString(str)
	}

	return s.String()
}

func Byte(n int, str string) string {
	var s = make([]byte, 0)
	for i := 0; i < n; i++ {
		s = append(s, str...)
	}

	return string(s)
}
